<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>个人信息-修改密码</title>
	<link rel="stylesheet" href="__PUBLIC__/Mobile/css/zhang.css">
	<script src="__PUBLIC__/Mobile/js/jquery-1.7.2.min.js"></script>
	<script src="__PUBLIC__/Mobile/Layer/layer.min.js"></script>
</head>

<body >
<section>
<!--修改密码-->
<form action=""> </form>
<div class="lm"> 
	<a href="javascript:history.back(-1);">
		<img src="__PUBLIC__/Mobile/images/return.png" style="height:22px; padding-left:2%; line-height:22px; width:6%; padding-top:2%;" class="left">
	</a>	
    <span class="left size20"><strong></strong>修改密码</span>
</div>
<div class="Logon1">
	<p>
    <span style=" width:100%">
	  <input type="password" placeholder="请输入原密码" name="password" onmouseout="mouseOut()">  
      </span> 
   </p>
	<p>
    <span style=" width:100%">
	  <input  type="password" placeholder="请输入新密码" name="newpassword"> 
      </span>  
   </p>
	<p>
	  <input type="password" placeholder="请再次输入新密码" name="newpasswordtwo">   
   </p>
</div>
<button class="immediately2 size26" style="border:none;font-size:1.4em;" id="button">确&nbsp;定</button>

</section>
<script>
	function mouseOut(){
	    var password = $("input[name=password]").val();
	    if(!password){
	    	return false;
	    }else{
	    	$.ajax({
	   			 url: "{:U('Mycenter/check_password')}",
	             type: "POST",
	             data: {password:password},
	             dataType: "json",
	             success: function(result){
	             	if(result.isok=='ok'){
	                 	layer.alert('您的原密码输入错误',5);
	               	}else if(result.isok=='off'){
	                 	return true;
	               	}
	            }
	        });
	    }
	}
	
	$("#button").click(function(){
		var password = $("input[name=password]").val();
		var newpassword = $("input[name=newpassword]").val();
		var newpasswordtwo = $("input[name=newpasswordtwo]").val();
		if(!password){
			layer.msg('请输入原密码',2);
	    	return false;
	    }
		if(!newpassword){
			layer.msg('请输入新密码',2);
	    	return false;
	    }
		if(!newpasswordtwo){
			layer.msg('请再次输入新密码',2);
	    	return false;
	    }
		if(newpassword != newpasswordtwo){
			layer.msg('两次输入的密码不一致',2);
	    	return false;
		}
		
		$.ajax({
  			 url: "{:U('Mycenter/change_password')}",
             type: "POST",
             data: {newpasswordtwo:newpasswordtwo},
             dataType: "json",
             success: function(result){
               	 if(result.isok=='ok'){
                	 layer.alert('密码修改成功,请重新登录',5);
                	 location.href = "{:U('User/login')}";
                 }else if(result.isok=='off'){
                	 layer.msg('修改失败',2);
                 }
             }
        });
	});
</script>
</body>
</html>
